package com.dml.webmagicd.init;

import com.dml.webmagicd.webmagic.start.Start;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.io.File;
import java.io.FileWriter;
import java.net.URL;
import java.util.List;

@Component
public class ApplicationStartInit implements CommandLineRunner {

  @Autowired
  private List<Start> list;

  @Override
  public void run(String... args) throws Exception {
    list.forEach(item -> {
      try {
        new Thread(item::start).start();
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    });
  }
}
